<template>
	<div class="bgBox">
		<div class="poster">
			<image src="https://www.baixuemianshi.com/zhuanti/images/logo2.png" class="logo" mode="widthFix"></image>
			<div class="infoBox">
				<h2>【雪恒教育-白雪面试】课前选班系统</h2>
				<h1>{{info.hdname}}</h1>
				<p>选择白雪面试请认准【雪恒教育】和【白雪老师】<br>💕白雪面试全称：【雪恒教育-白雪面试】💕<br>其它以白雪 * * 机构命名的机构，均非白雪面试官方</p>
				<div class="btnBox" v-if="info">
					<u-button type="error" shape="circle" text="开始填写" @click="towebview"></u-button>
				</div>
			</div>
			<image src="https://www.baixuemianshi.com/zhuanti/form/images/xbj.jpg" class="bottom" mode="widthFix"></image>
		</div>
	</div>
</template>

<script>
const db = wx.cloud.database();
export default {
	name: 'headcomd',
	data() {
		return {
			hdid: "",
			openid: "",
			info: ""
		};
	},
	onShareAppMessage(options) {
		let that = this
		var shareObj = {
		    title: '【雪恒教育-白雪面试】课前选班系统',    // 默认是小程序的名称(可以写slogan等)
		    path: '/pages/huodong/form/index?hdid=' + that.hdid,    // 默认是当前页面，必须是以‘/'开头的完整路径
		    imageUrl: '',   //自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
		    success: function(res){
		      // 转发成功之后的回调
		      if(res.errMsg == 'shareAppMessage:ok'){
		      }
		    }
		  };
		  return shareObj
	},
	onLoad(options) {
		this.hdid = options.hdid
	},
	computed: {},
	mounted() {
		
	},
	watch: {},
	created() {
		let that = this;
		that.getopenid()
		
	},
	methods: {
		getopenid() {
			let that = this;
			wx.cloud.callFunction({
				name: 'getopenid',
				data: {},
				complete: res => {
					that.openid = res.result.openid
					that.getPageinfo()
				}
			});
		},
		getPageinfo(){
			let that = this
			db.collection('form_kf_hd').doc(that.hdid).get({
				success: res => {
					that.info = res.data
				},
				fail: req => {
					console.log(req)
				}
			})
		},
		towebview(){
			uni.navigateTo({
				url: '../../webview/index?href=' + encodeURIComponent('https://www.baixuemianshi.com/zhuanti/form/?hdid=' + this.hdid + '&userid=' + this.openid)
			})
		}
	}
};
</script>

<style>
@import url(./index.css);
</style>
